package com.xfp.mapper;

import com.xfp.anntation.AutoFill;
import com.xfp.enumclass.OperationClass;
import com.xfp.pojo.dto.CategoryDto;
import com.xfp.pojo.dto.CategoryQueryDto;
import com.xfp.pojo.entity.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {

    /**
     * 根据分类id去查询分类是否存在
     * @param classId
     * @return
     */
    @Select("select * from tb_sku_class where class_id =#{classId}")
    Category findById(Integer classId);

    /**
     * 根据名称去查询是分类否存在
     * @param className
     * @return
     */
    @Select("select * from tb_sku_class where class_name =#{className}")
    Category findByName(String className);

    /**
     * 新增分类
     * @param categoryDto
     * @return
     */
    @Insert("insert into tb_sku_class (class_name) values (#{className})")
    int insert(CategoryDto categoryDto);

    /**
     *分页查询
     * @param categoryQueryDto
     * @return
     */
    List<Category> pageQuery(CategoryQueryDto categoryQueryDto);

    /**
     * 根据id删除分类信息
     * @param classId
     */
    @Delete("delete from tb_sku_class where class_id =#{classId}")
    void deleteById(Integer classId);

    /**
     * 根据id修改分类信息
     * @param categoryDto
     * @return
     */
    @Update("update  tb_sku_class set class_name = #{className} where class_id = #{classId}")
    int update(CategoryDto categoryDto);
}
